import Ember from 'ember';
import config from "game-front/config/environment";

export default Ember.Route.extend({
	share: Ember.inject.service(),
	beforeModel: function (posts, transition) {
		Ember.run.scheduleOnce('afterRender', this, function () {
			Ember.$(".user-background").height(document.body.scrollHeight);
		});
	},
	model(params) {
		var userInfo = this.modelFor("application");
		console.log(userInfo);
		return Ember.$.getJSON(config.apiBase + "rankings/game", {
			userId: userInfo ? userInfo.userId : 'none',
			gameZoneProductId: 1,
			gameId:params.gameId
		});
	},
	afterModel() {
		var share = this.get("share");
		var userId = sessionStorage.getItem("userId");
		var link = window.location.origin + config.baseURL + "beforewinnersshare?key=" + userId;

		var shareLink = {
			title: '棒打疯猫-上期获奖名单', // 分享标题
			desc: '获奖名单来了，快来膜拜一下吧',
			link: link + "#public=true", // 分享链接
			imgUrl: 'http://game.inkanke.com/yydb/assets/images/banner-62c08e1120ab2db597edb26e069052c5.png', // 分享图标
			success: function () {
				share.reward(userId);

			},
			cancel: function () {
				// 用户取消分享后执行的回调函数
			}
		};
		share.config(shareLink);
	},
	actions: {
		showShare() {
			console.log("adfd");
			$(".shade-share").css({"display": "block"});
		},
		hidder(){
			$(".shade-share").css({"display": "none"});
		}
	}
});
